import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    proxy: {
      '/api': {
        // /api => http://localhost:3000/api
        target: 'http://localhost:3000', // 将请求转发到的目标地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '') // 可选的重写路径
      }
    }
  },

  plugins: [react()],

  resolve: {
    alias: {
      '@': '/src'
    }
  },

  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import '@/styles/variables.scss';`
      }
    }
  }
})
